﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace HZ.Common
{
    public  class DT2String
    {
        /// <summary>
        /// 将表中的某一转成分割形式的字符串集
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="colName"></param>
        /// <returns></returns>
        public static string ConvertToSpiltString(DataTable dt, string colName,string spr) {
            StringBuilder sb = new StringBuilder(dt.Rows.Count * dt.Columns.Count);
            foreach (DataRow row in dt.Rows)
            {
                if (row[colName]!=null)
                {
                    sb.AppendFormat("{0}{1}",row[colName],spr);
                }
            }
            return sb.ToString().TrimEnd(spr.ToCharArray());
        }
    }
}
